package com.chezhujie.www.service;

import com.chezhujie.www.domain.Czjlike;
import com.chezhujie.www.persistence.CzjlikeMapper;
import com.xy.core.exception.ClassCheckException;
import com.xy.user.base.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


/**
 * 用户评论点赞
 * Created by 汤伟杰 on 2017/5/23.
 */
@Service
public class CzjlikeService extends BaseService<Czjlike> {
    @Autowired
    private CzjlikeMapper czjlikeMapper;

    @Autowired
    public void setBaseMapper(CzjlikeMapper czjlikeMapper) {
        this.baseMapper = czjlikeMapper;
    }

    public List<Map<String,Object>> getListCommentsId(Map<String, Object> param) {
        return czjlikeMapper.listCommentsId(param);
    }
    public List<Map<String,Object>> getListUserinfoId(Map<String, Object> param) {
        return czjlikeMapper.listUserinfoId(param);
    }

    public void checkEntity(Czjlike czjlike) throws ClassCheckException {
        if(czjlike.getLikeId()!=null&&czjlike.getLikeId().length()>19){
            throw new ClassCheckException("用户评论点赞点赞主键不能超过19个字符");
        }
        if(czjlike.getCommentsId()!=null&&czjlike.getCommentsId().length()>19){
            throw new ClassCheckException("用户评论点赞评论不能超过19个字符");
        }
    }
    public void checkListEntity(List<Czjlike> listCzjlike) throws ClassCheckException {

        for (Czjlike czjlike : listCzjlike) {
            checkEntity(czjlike);
        }

    }
}
